home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Day Cry
/
Day Cry CD.bin
/
oh_towns
/
tetujin
/
src.lzh
/
G_EFF
/
SOFT.C
< prev
next >
Wrap
Text File
|
1994-08-27
|
2KB
|
116 lines
/*
graphic effect lib.
Soft
h. Toda 1994 8 22
*/
#include <stdio.h>
#include <stdlib.h>
#include <egb.h>
#include "g_eff.h"
#define NOERR 0 /* no error */
static int mx ;
static int aSen ;
static int mSen ;
static int cMax ;
static int aMax ;
static int x1 ;
static int y1 ;
static int x2 ;
static int y2 ;
static int (*read1)() ;
static int (*write)() ;
static int (*mask)() ;
g_softnessFilter( BASICPARA *para, int rate )
{
unsigned char a[10][4] ;
int i, x, y ;
int n ;
int k1, k2 ;
mx = para->mix ;
aSen = para->alphaSen ;
mSen = para->maskSen ;
cMax = para->colorMax ;
aMax = para->alphaMax ;
x1 = para->lupx ;
y1 = para->lupy ;
x2 = para->rdwx ;
y2 = para->rdwy ;
read1 = para->read1 ;
write = para->write ;
mask = para->mask ;
k1 = rate >> 3 ;
k2 = 256 - k1*8 ;
for( y = y1 ; y <= y2 ; y++ )
{
for( x=x1 ; x <= x2 ; x++ )
{
read1( x-1, y-1, a[0] ) ;
read1( x, y-1, a[1] ) ;
read1( x+1, y-1, a[2] ) ;
read1( x-1, y, a[3] ) ;
read1( x, y, a[4] ) ;
read1( x+1, y, a[5] ) ;
read1( x-1, y+1, a[6] ) ;
read1( x, y+1, a[7] ) ;
read1( x+1, y+1, a[8] ) ;
for( i=0 ; i<3 ; i++ )
{
int total ;
total = k1*( (int)(a[0][i]) + a[1][i] + a[2][i] +
a[3][i] + a[5][i] +
a[6][i] + a[7][i] + a[8][i]
) +
k2*( (int)(a[4][i]) ) ;
total = (total + 128) >> 8 ;
if( total < 0 )total = 0 ;
if( total > 255 )total = 255 ;
a[9][i] = total ;
}
mixWrite( x, y, a[9], a[4] ) ;
}
}
return NOERR ;
}
static mixWrite( int x, int y, unsigned char *a, unsigned char *b )
{
unsigned char c[4] ;
int mix ;
if( mSen )
{
if( mask( x, y ) >= mSen )
return NOERR ;
}
mix = mx ;
if( aSen )
{
mix = mix * b[3] / aMax ;
}
c[0] = ( a[0] * mix + b[0] * ( 256 - mix ) + 0x80 ) >> 8 ;
c[1] = ( a[1] * mix + b[1] * ( 256 - mix ) + 0x80 ) >> 8 ;
c[2] = ( a[2] * mix + b[2] * ( 256 - mix ) + 0x80 ) >> 8 ;
c[3] = b[3] ;
if( mix )
{
write( x, y, c ) ;
}
return NOERR ;
}